#用python获取某城市的天气情况
import requests
while True:
    city=input('please input your city:\n')
    if not city:
        break
    try:
        req=requests.get('http://wthrcdn.etouch.cn/weather_mini?city=%s'%city)
        req.encoding='utf-8'
        weather=req.json()
        city_data=weather['data']
        print('current weather:',city_data.get('wendu'),'℃',
              city_data.get('ganmao'))
        print('Next 4 days weather:')
        city_forecast_6=city_data['forecast'][0]
        city_forecast_7=city_data['forecast'][1]
        city_forecast_8=city_data['forecast'][2]
        city_forecast_9=city_data['forecast'][3]
        print(city_forecast_6.get('date'),
              city_forecast_6.get('high'),
              city_forecast_6.get('low'),
              city_forecast_6.get('type')
              )
        print(city_forecast_7.get('date'),
              city_forecast_7.get('high'),
              city_forecast_7.get('low'),
              city_forecast_7.get('type')
              )
        print(city_forecast_8.get('date'),
              city_forecast_8.get('high'),
              city_forecast_8.get('low'),
              city_forecast_8.get('type')
              )
        print(city_forecast_9.get('date'),
              city_forecast_9.get('high'),
              city_forecast_9.get('low'),
              city_forecast_9.get('type')
              )
    except:
        print('Research false')